<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        td {
            width: 100px;
            border: 1px solid black;
            height: 50px;
        }
    </style>
</head>
<body>
<input id="add_name" name="add_name" type="text">
<button id="btn">sss</button>
<table>
    <tr class="tr1">
        <td>1</td>
    </tr>
    <tr>
        <td>1</td>
    </tr>
</table>
<script>
    document.getElementById('btn').onclick = function () {
        let input = document.getElementById('add_name')
        let input2 = document.getElementsByName('add_name')
        console.log(input.value)
        console.log(input2.value)
    }

    let trList = document.getElementsByTagName('tr');
    for (let i = 0; i < trList.length; i++) {
        trList[i].onclick = function () {
            //调用你的方法
        }
    }

    document.getElementsByTagName("tr").onclick = function () {
        alert('ok')
    }
</script>
</body>
</html>
